from appium import webdriver
from selenium.webdriver.common.by import By

# 字典
# 1.设置终端参数项
desired_caps = {
    "platformName": "Android",
    "platformVersion": "5.1.1",
    "deviceName": "Samsung Galaxy S10",
    "appPackage": "com.tal.kaoyan",
    "appActivity": "com.tal.kaoyan.ui.activity.SplashActivity",
    "noReset": True
}
# 2.appium server进行启动

# 3.发送指令给到appium server
driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", desired_caps)

# 点击取消
el_cancle = driver.find_element(By.ID, "android:id/button2")
el_cancle.click()
# 获取屏幕的尺寸
window_size = driver.get_window_size()
print("手机屏幕的尺寸", window_size)
x = window_size["width"]
y = window_size["height"]
# 左滑两次
for i in range(0, 2):
    driver.swipe(start_x=x * 0.9,
                 start_y=y * 0.5,
                 end_x=x * 0.3,
                 end_y=y * 0.5,
                 duration=100)
# 点击立即体验
el_tiyan = driver.find_element(By.ID, "com.tal.kaoyan:id/activity_splash_guidfinish")
el_tiyan.click()
#
